package o;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import androidx.annotation.NonNull;
import com.huawei.appgallery.assistantdock.base.externalaction.OpenViewAction;
import com.huawei.appgallery.assistantdock.buoydock.uikit.remote.RemoteBuoyCallback;
import com.huawei.appgallery.assistantdock.buoydock.uikit.remote.RemoteBuoyRequest;
import com.huawei.gamebox.plugin.gameservice.bean.GameInfo;
import com.huawei.hmf.annotation.ApiDefine;
import com.huawei.hmf.annotation.Singleton;
import o.dex.a;

@ApiDefine(uri = bgp.class)
@Singleton
public class bgo implements bgp, fae, fad {
    private fkh<RemoteBuoyCallback> ˊ;
    private GameInfo ˋ;
    private a ˎ;
    private bfm ˏ = null;

    public fkd<RemoteBuoyCallback> ˏ(@NonNull String str, @NonNull RemoteBuoyRequest remoteBuoyRequest, @NonNull GameInfo gameInfo) {
        this.ˊ = new fkh();
        this.ˋ = gameInfo;
        Bundle bundle = null;
        if (remoteBuoyRequest != null) {
            this.ˎ = ˋ(remoteBuoyRequest.ˏ());
            bundle = remoteBuoyRequest.ॱ();
        }
        fai ˋ = bgu.ˋ(str);
        if (ˋ == null) {
            this.ˊ.ˋ(new RuntimeException("can not create the window by uri"));
        } else {
            ˊ(ˋ, bundle);
        }
        return this.ˊ.ˊ();
    }

    public void ˊ() {
        Logger.ˎ("RemoteBuoyImpl", "Enter close");
        ˏ();
    }

    public void onShow() {
        Logger.ˎ("RemoteBuoyImpl", "onShow");
        if (this.ˊ != null) {
            Logger.ˎ("RemoteBuoyImpl", "tssCallback.onNext:WINDOW_OPEN");
            this.ˊ.ˋ(new RemoteBuoyCallback(0, (Intent) null));
        }
    }

    public void onClose() {
        Logger.ˎ("RemoteBuoyImpl", "onClose");
        if (this.ˊ != null) {
            Logger.ˎ("RemoteBuoyImpl", "tssCallback.onNext:WINDOW_CLOSE");
            this.ˊ.ˋ(new RemoteBuoyCallback(1, (Intent) null));
        }
    }

    public void onHide() {
        Logger.ˎ("RemoteBuoyImpl", "onClose");
        if (this.ˊ != null) {
            Logger.ˎ("RemoteBuoyImpl", "tssCallback.onNext:NOTIFY_ALL_WINDOW_CLOSE");
            this.ˊ.ˋ(new RemoteBuoyCallback(2, (Intent) null));
        }
    }

    public void onFail(String str) {
        if (this.ˊ != null) {
            this.ˊ.ˋ(new RemoteBuoyCallback(1, (Intent) null));
        }
    }

    public GameInfo getGameInfo() {
        return this.ˋ;
    }

    public bfm getRequestParams() {
        if (this.ˏ == null) {
            this.ˏ = new bfm();
        }
        this.ˏ.ˏ(this.ˎ);
        return this.ˏ;
    }

    private void ˊ(@NonNull fai o_fai, Bundle bundle) {
        new Handler(Looper.getMainLooper()).post(new 3(this, bundle, o_fai));
    }

    private void ˏ() {
        new Handler(Looper.getMainLooper()).post(new Runnable(this) {
            final /* synthetic */ bgo ˋ;

            {
                this.ˋ = r1;
            }

            public void run() {
                Context ˋ = ContentManager.getInstant().getContext();
                fam.ॱ().ˋ(null);
                fam.ॱ().ˎ(ˋ);
                if (this.ˋ.ˊ != null) {
                    Logger.ˎ("RemoteBuoyImpl", "tssCallback.onNext:NOTIFY_ALL_WINDOW_CLOSE");
                    this.ˋ.ˊ.ˋ(new RemoteBuoyCallback(2, (Intent) null));
                }
            }
        });
    }

    private a ˋ(int i) {
        if (i == a.RIGHT.ˋ()) {
            return a.RIGHT;
        }
        return a.LEFT;
    }

    public void ˎ(int i) throws RemoteException {
    }

    public void ˋ(String str, String str2) throws RemoteException {
    }

    public void ˎ(String str) throws RemoteException {
        Context ˋ = ContentManager.getInstant().getContext();
        Intent intent = new Intent(OpenViewAction.ACTION_OPEN_VIEW);
        intent.setPackage(ˋ.getPackageName());
        intent.putExtra("taskId", str);
        intent.addFlags(268468224);
        ˋ.startActivity(intent);
    }

    public IBinder asBinder() {
        return null;
    }
}
